<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('添加映射信息')"/>
</head>
<body>
    <form class="layui-form" action="" onsubmit="return false">
        <div class="mainBox">
            <div class="main-container">
                <div class="layui-form-item">
                    <label class="layui-form-label">字段类型</label>
                    <div class="layui-input-block">
                        <input type="text" name="columnType" required  lay-verify="required" lay-affix="clear" placeholder="字段类型" autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">属性类型</label>
                    <div class="layui-input-block">
                        <input type="text" name="attrType" required  lay-verify="required" lay-affix="clear" placeholder="属性类型" autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">属性包名</label>
                    <div class="layui-input-block">
                        <input type="text" name="packageName" lay-affix="clear" placeholder="属性类型" autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-input-block">
                        <button class="pear-btn pear-btn-md pear-btn-radius pear-btn-primary "  lay-submit lay-filter="formDemo">确定</button>
                        <button type="reset" class="pear-btn pear-btn-md  pear-btn-radius">取消</button>
                    </div>
                </div>
            </div>
        </div>
    </form>
    <th:block th:include="include :: footer"/>
    <script>
        let prefix = "/mapping/";
        layui.use(['form','http'], function(){
            const form = layui.form;
            let http = layui.http;

            form.on('submit(formDemo)', function(data){
                http.request({
                    url: prefix+"save",
                    contentType: http.contentType.json,
                    data:data.field,
                    method:"POST"
                }).then(res=>{
                    layer.msg(res.message,{icon:1,time:1000},function(){
                        parent.layer.close(parent.layer.getFrameIndex(window.name));//关闭当前页
                        parent.layui.table.reload("mapping-table");
                    });
                }).catch(e=>{
                    console.log(e)
                })
                return false;
            });
        });
    </script>
</body>
</html>